#ifndef allegro_backend_h__
#define allegro_backend_h__

#include <GTL.h>
#include <GTLEngine.h>

struct AB_Impl;
class AllegroBackend : public GTL::Engine::BackendInterface
{
public:
	GTL::Engine::Game* mGame;
	AB_Impl* pImpl;

	virtual void Init(GTL::Engine::Game* game, int width, int height, bool fullscreen);
	virtual void RegisterServices();
	virtual void Destroy();

	virtual GTL::Engine::ImageRef* LoadImage(const char* filename, bool is_cache_ok);
	virtual GTL::Engine::FontRef* LoadFont(const char* filename);
	virtual GTL::Engine::ShaderRef* LoadShader(const char* vshader, const char* pshader);

	virtual GTL::Engine::ImageRef* CreateRenderTarget(size_t width, size_t height);
	virtual void SetRenderTarget(GTL::Engine::ImageRef* target);

	virtual void ClearScreen(const GTL::Engine::ColorRGBA& color);
  virtual void PutPixel(const GTL::Engine::Point& pos, const GTL::Engine::ColorRGBA& color);
	virtual void DrawRect(const GTL::Engine::Rect& rect, const GTL::Engine::ColorRGBA& color, const GTL::Engine::ColorRGBA& fillcolor);
	virtual void DrawLine(float x, float y, float x2, float y2, const GTL::Engine::ColorRGBA& color);
  virtual void LockDrawing(bool lock);

	virtual GTL::Geometry2D::GenericRectangle2D<float> GetClippingRect();
	virtual void SetClippingRect(const GTL::Geometry2D::GenericRectangle2D<float>& rect);

	virtual void SetBlendingMode(int mode);

	virtual void UnuseShader();

	virtual void DestroyImage(GTL::Engine::ImageRef* ref);
	virtual void DestroyFont(GTL::Engine::FontRef* ref);
	virtual void DestroyShader(GTL::Engine::ShaderRef* ref);

	virtual void DebugLog(const char* str, int type);

	virtual uint64_t GetTimeMsec();
	virtual double GetTimeSec();

	int DoInput(float dt);

	GTL::Engine::Service* mInputService;
	GTL::Engine::Service* mPreDrawService;
	GTL::Engine::Service* mPostDrawService;
};

#endif // allegro_backend_h__